let context = null
const initContext = (vue) => {
	context = vue;
}

const showModalPromise = () => {
	return new Promise((resolve, reject) => {
		uni.showModal({
			title: '是否授权当前位置',
			content: '需要获取您的地理位置，请确认授权',
			success: res => {
				resolve(res);
			},
			fail: error => {
				reject(error);
			},
		});

	})
}

const GetLocationPromise = () => {
	return new Promise((resolve, reject) => {
		uni.getLocation({
			type: 'gcj02',
			success: res => {
				resolve(res);
			},
			fail: error => {
				reject(error);
			},
			//complete: () => {}
		});
	});
}

const OpenSettingPromise = () => {
	return new Promise((resolve, reject) => {
		uni.openSetting({
			success: res => {
				resolve(res);
			},
			fail: error => {
				reject(error);
			},
		})
	});
}

const uniApiPromise = {
	initContext,
	showModalPromise,
	GetLocationPromise,
	OpenSettingPromise
}

export default uniApiPromise
